package com.by.controller;

import com.by.bean.TaoCan;
import com.by.common.bean.ResultBean;
import com.by.common.controller.BaseController;
import com.by.service.TaoCanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "套餐管理")
@RequestMapping("/api")
public class TaoCanController extends BaseController {

    @Autowired
    TaoCanService taoCanService;

    @ApiOperation("保存套餐")
    @PostMapping("/taocan")
    public ResultBean save(@RequestBody List<TaoCan> taoCans) {
        int rs = taoCanService.save(taoCans);
        return rs > 0 ? success("保存成功") : fail("保存失败");
    }

    @ApiOperation("套餐列表")
    @GetMapping("/taocan")
    public ResultBean<TaoCan> query() {
        List list = taoCanService.query();
        return success("套餐列表", list);
    }

}
